A motor controller known in the art includes a safety circuit that stops a motor in a safe manner in response to, for example, an input from an emergency stop switch (Patent Literature 1). A motor controller described in Patent Literature 1 includes a safety circuit (a safety stop circuit) arranged between a pulse width modulation (PWM) circuit, which generates a PWM signal for driving a motor, and a drive circuit, which drives an inverter. The safety circuit includes a three-state buffer. The safety circuit uses an input from a motor stop switch as an input for controlling the three-state buffer to cut off a PWM signal that is input into the drive circuit.